<?php

    #-------------------------------------------------------------#
	# This file is part of the Tekuna MVC Microframework for PHP. #
	# (c) 2009 Niels Jäckel <niels.jaeckel@tekuna.org>            #
	# Please visit http://tekuna.org/ for more information.       #
	#                                                             #
	# This software is licensed under the MIT License. Please     #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#


	Tekuna :: load('org.tekuna.core.filter.TekunaFilter');


	/**
	 * This filter can be used to sanitize inputs that will be part
	 * of SQL statements. It is a combination of addslashes and some
	 * control character replacements.
	 */

	class SQLFilter implements TekunaFilter {


		/**
		 * Apply the filter
		 *
		 * @param mixed $mInput
		 * @return string
		 */

		public function filter($mInput) {

			// standard escapes
			$mInput = addslashes($mInput);

			// special escapes
			$mInput = str_replace("\n", "\\\n", $mInput);
			$mInput = str_replace("\r", "\\\r", $mInput);
			$mInput = str_replace("\t", "\\\t", $mInput);
			$mInput = str_replace("\x1a", "\\\x1a", $mInput);

			return $mInput;
		}
	}
